package com.yuanlrc.base.entity.admin;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.yuanlrc.base.annotion.ValidateEntity;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.util.Date;

/**
 * 后台学生(普通用户)实体类
 *
 */

@Entity
@Table(name="ylrc_student")
@EntityListeners(AuditingEntityListener.class)
public class Student extends BaseEntity {

    private static final int STUDENT_SEX_MAN = 1;//性别男

    private static final int STUDENT_SEX_WOMAN = 2;//性别女

    private static final int STUDENT_SEX_UNKONW = 0;//性别未知

    @ManyToOne
    @JoinColumn(name="role_id")
    private Role role;//学生所属角色

    @ValidateEntity(required=true,requiredLeng=true,minLength=5,maxLength=5,errorRequiredMsg="学号不能为空!",errorMinLengthMsg="学号长度需为5!",errorMaxLengthMsg="学号名称长度需为5!")
    @Column(name="student_id",nullable=false,length=5,unique=true)
    private String studentId;//学号

    @ValidateEntity(required=false,requiredLeng=true,minLength=1,maxLength=18,errorRequiredMsg="姓名不能为空!",errorMinLengthMsg="姓名长度需大于1!",errorMaxLengthMsg="角色名称长度不能大于18!")
    @Column(name="student_name",nullable=false,length=18)
    private String studentName;//姓名

    @ValidateEntity(required=true,requiredLeng=true,minLength=4,maxLength=32,errorRequiredMsg="密码不能为空！",errorMinLengthMsg="密码长度需大于4!",errorMaxLengthMsg="密码长度不能大于32!")
    @Column(name="password",nullable=false,length=32)
    private String password;//登录密码

    @ValidateEntity(required=false)
    @Column(name="head_pic",length=128)
    private String headPic;//用户头像

    @ValidateEntity(required=false)
    @Column(name="mobile",length=12)
    private String mobile;//用户手机号

    @ValidateEntity(required=false)
    @Column(name="sex",length=1)
    private int sex = STUDENT_SEX_UNKONW;//性别

    @ManyToOne
    @JoinColumn(name="faculties_id")
    private Faculties faculties;//所属学院

    @ManyToOne
    @JoinColumn(name="clazz_id")
    private Clazz clazz;//所属班级

    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }

    public String getStudentId() {
        return studentId;
    }

    public void setStudentId(String studentId) {
        this.studentId = studentId;
    }

    public String getStudentName() {
        return studentName;
    }

    public void setStudentName(String studentName) {
        this.studentName = studentName;
    }

    public int getSex() {
        return sex;
    }

    public void setSex(int sex) {
        this.sex = sex;
    }

    public Faculties getFaculties() {
        return faculties;
    }

    public void setFaculties(Faculties faculties) {
        this.faculties = faculties;
    }

    public Clazz getClazz() {
        return clazz;
    }

    public void setClazz(Clazz clazz) {
        this.clazz = clazz;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getHeadPic() {
        return headPic;
    }

    public void setHeadPic(String headPic) {
        this.headPic = headPic;
    }

    @Override
    public String toString() {
        return "Student{" +
                "role=" + role +
                ", studentId='" + studentId + '\'' +
                ", studentName='" + studentName + '\'' +
                ", password='" + password + '\'' +
                ", headPic='" + headPic + '\'' +
                ", mobile='" + mobile + '\'' +
                ", sex=" + sex +
                ", faculties=" + faculties +
                ", clazz=" + clazz +
                '}';
    }
}
